<template>
	<view>
		<custom-header title="扣款记录" />
		<view class="_wrap">
			<view class="tabs_wrap">
				<view 
					class="list" 
					:class="tab == item.id?'active':''" 
					v-for="(item,index) in tabsList" 
					:key="index"
					@click="handleTab(item)">
					{{ item.name }}
				</view>
			</view>
			<scroll-view
				:scroll-y="true" 
				scroll-with-animation
				:style="{height:'calc(100vh - 85rpx - '+statusBarHeight+'px)'}"
				class="scroll_content_wrap">
					<view
						class="no_data" 
						v-if="!listData.length && listLoading != 'loading'">
							<view class="icon">
								<image src="https://goods-1312936761.cos.ap-chongqing.myqcloud.com/applet/supplier/my/nodata.png" mode=""></image>
							</view>
					</view>
					<view class="list_wrap" v-if="listData.length">
						<view 
							class="list" 
							v-for="(item,index) in listData" 
							:key="index"
							hover-class="custom_hover"
							:hover-stay-time="200"
							@click="handleDetail">
							<view class="title_price">
								<view class="title">
									<view class="icon">
										<image src="https://goods-1312936761.cos.ap-chongqing.myqcloud.com/applet/supplier/wallet/withhold_icon.png" mode=""></image>
									</view>
									<view class="text">{{ item.time1 }}</view>
								</view>
								<view class="price">-{{ item.price }}元</view>
							</view>
							<view class="info">
								<view class="label">类型：</view>
								<view class="value">
									{{ item.type }}
								</view>
							</view>
							<view class="info">
								<view class="label">备注：</view>
								<view class="value">
									{{ item.remark }}
								</view>
							</view>
							<view class="info">
								<view class="label">时间：</view>
								<view class="value">
									{{ item.time2 }}
								</view>
							</view>
						</view>
					</view>
					<view class="loading_wrap" v-if="listLoading == 'loading'">
						<up-loadmore
							:status="listLoading"
							iconSize="22"
							iconColor="#FF3316"
							loadingIcon='semicircle'
							loadingText=""
							/>
					</view>
			</scroll-view>
		</view>
	</view>
</template>

<script setup>
	import { computed, ref , onMounted} from 'vue';
	import { useStore } from 'vuex';
	const store = useStore()
	
	const statusBarHeight = computed(()=>{
		return store.getters.statusBarHeight
	})
	
	const tab = ref(1)
	const tabsList = ref([
		{ id:1,name:'本月' },
		{ id:2,name:'全部' },
	])
	// 选择tabs
	const handleTab = (e)=>{
		console.log(e)
		tab.value = e.id
		loadGetListData()
	}
	
	// 获取列表数据
	const listLoading = ref('loadmore');
	const listData = ref([]);
	const loadGetListData = ()=>{
		listData.value = []
		listLoading.value = 'loading'
		setTimeout(()=>{
			listData.value = [
				{
					
					id:1,
					time1:'2024-10-22',
					price:'38.00',
					type:'代扣款',
					remark:'2024-10-21  缺货罚款',
					time2:'2025-04-06  06:30:53'
				},
				{
					
					id:1,
					time1:'2024-10-22',
					price:'38.00',
					type:'代扣款',
					remark:'2024-10-21  缺货罚款',
					time2:'2025-04-06  06:30:53'
				},
				{
					
					id:1,
					time1:'2024-10-22',
					price:'38.00',
					type:'代扣款',
					remark:'2024-10-21  缺货罚款',
					time2:'2025-04-06  06:30:53'
				},
				{
					
					id:1,
					time1:'2024-10-22',
					price:'38.00',
					type:'代扣款',
					remark:'2024-10-21  缺货罚款',
					time2:'2025-04-06  06:30:53'
				},
				{
					
					id:1,
					time1:'2024-10-22',
					price:'38.00',
					type:'代扣款',
					remark:'2024-10-21  缺货罚款',
					time2:'2025-04-06  06:30:53'
				},
				{
					
					id:1,
					time1:'2024-10-22',
					price:'38.00',
					type:'代扣款',
					remark:'2024-10-21  缺货罚款',
					time2:'2025-04-06  06:30:53'
				},
				{
					
					id:1,
					time1:'2024-10-22',
					price:'38.00',
					type:'代扣款',
					remark:'2024-10-21  缺货罚款',
					time2:'2025-04-06  06:30:53'
				},
				{
					
					id:1,
					time1:'2024-10-22',
					price:'38.00',
					type:'代扣款',
					remark:'2024-10-21  缺货罚款',
					time2:'2025-04-06  06:30:53'
				},
				{
					
					id:1,
					time1:'2024-10-22',
					price:'38.00',
					type:'代扣款',
					remark:'2024-10-21  缺货罚款',
					time2:'2025-04-06  06:30:53'
				},
				{
					
					id:1,
					time1:'2024-10-22',
					price:'38.00',
					type:'代扣款',
					remark:'2024-10-21  缺货罚款',
					time2:'2025-04-06  06:30:53'
				},
				{
					
					id:1,
					time1:'2024-10-22',
					price:'38.00',
					type:'代扣款',
					remark:'2024-10-21  缺货罚款',
					time2:'2025-04-06  06:30:53'
				}
			]
			listLoading.value = 'loadmore'
		},1000);
	};
	const handleDetail = (item)=>{
		uni.navigateTo({
			url:'/pages/withholdRecordDetail/withholdRecordDetail?id='+item.id
		})
	}
	
	
	onMounted(()=>{
		loadGetListData();
	})
	
</script>

<style lang="scss">
	._wrap{
		padding: 0 20rpx;
	}
	.tabs_wrap{
		display: flex;
		height: 82rpx;
		.list{
			flex: 1;
			text-align: center;
			padding: 20rpx 0;
			color: #999;
			font-size: 32rpx;
			position: relative;
			&.active{
				color: #333333;
				font-weight: bold;
				&::after{
					content: '';
					width: 28rpx;
					height: 8rpx;
					background: #FF3316;
					border-radius: 8rpx;
					position: absolute;
					bottom: 8rpx;
					left: 50%;
					margin-left: -14rpx;
				}
			}
		}
	}
	.list_wrap{
		padding-bottom: 20rpx;
		.list{
			border-radius: 10rpx;
			background: #FFFFFF;
			padding: 20rpx;
			margin-top: 20rpx;
			.title_price{
				font-weight: bold;
				font-size: 32rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding-bottom: 10rpx;
				.title{
					display: flex;
					align-items: center;
					.icon{
						width: 28rpx;
						height: 27rpx;
						display: flex;
					}
					.text{
						padding-left: 10rpx;
						color: #333333;
					}
				}
				.price{
					color:#C60C0C;
				}
			}
			.info{
				display: flex;
				padding-top: 10rpx;
				font-size: 24rpx;	
				.label{
					color: #999999;
				}
				.value{
					color: #333333;
				}
			}
		}
	}
	.no_data{
		background: #fff;
		border-radius: 10rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		margin: 20rpx;
		height: calc(100% - 40rpx);
		.icon{
			width: 280rpx;
			height: 322rpx;
		}
	}
</style>
